Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix suggestions with multiple corrections #129

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mfittko
Copy link

@mfittko mfittko commented Nov 4, 2024

The suggestions feature is broken as it's ignoring any offenses with multiple corrections. This is leading to wrong or - at best - incomplete sugggestions.

Fixes #81 and #96

Examples (before fix):
Screenshot 2024-11-04 at 13 48 14
Screenshot 2024-11-04 at 16 56 14

Examples (with fix):
Screenshot 2024-11-04 at 16 45 18
image

@mfittko
Copy link
Author

mfittko commented Nov 6, 2024

We're using this branch now as we think that the change is working well. Unfortunately this is not well covered by tests (yet) though, so if someone is able to help ot there, feel free to reach out.

Anyone who's relying on this, feel free to use our fork's branch until this is merged. If you see any issues, please post them here.

@mfittko
Copy link
Author

mfittko commented Nov 8, 2024

@haya14busa I think I fixed the issue and verified with a local devcontainer setup (see PR #130 )

@mfittko
Copy link
Author

mfittko commented Nov 24, 2024

can we trigger the workflows again? we're using this for 2 weeks now for most of our repos without a problem and we would like to see this in upstream

@@ -90,23 +90,44 @@ def build_range(offense)
# @param [RuboCop::Cop::Offense] offense
# @return [Array{Hash}]
def build_suggestions(offense)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has two Rubocop metrics based warnings since it's a larger method now. Perhaps determining the positions/range and sorted corrections could each be extracted into a private method?

We don't see to have tests for this other than integration tests through Rubocop CLI. If its easier to write a unit test that would be fine but is there anyway we could update the test data with samples that would trigger the warnings before this change and then include it here to demonstrate that the fix is working as expected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Style/MethodDefParentheses creates a suggestion with just one opening parenthese
2 participants